package gene.android.accountingpro.equations;

import gene.android.accountingpro.finals.EquationNames;
import gene.android.accountingpro.finals.FieldList;

import java.util.ArrayList;
import java.util.List;

public class AccountsReceivableTurnoverRatio extends Equation {
	
	private double net_credit_sales;
	private double average_net_accounts_receivable;
	
	public AccountsReceivableTurnoverRatio(){}
	
	public AccountsReceivableTurnoverRatio( double netCredSales, double averageNetAccountsReceivable )
	{
		this.net_credit_sales = netCredSales;
		this.average_net_accounts_receivable = averageNetAccountsReceivable;
		value = ( net_credit_sales / average_net_accounts_receivable );
	}
	
	

	@Override
	public String getEquationName() {
		return EquationNames.ACCOUNTS_RECEIVABLE_TURNOVER_RATIO;
	}

	@Override
	public List<String> getRequiredFields() {
		List<String> requiredFields = new ArrayList<String>();
		requiredFields.add( FieldList.NET_CREDIT_SALES );
		requiredFields.add( FieldList.AVERAGE_NET_ACCOUNTS_RECEIVABLE );
		return requiredFields;
	}

	@Override
	public void setValues(double[] values) {
		net_credit_sales = values[0];
		average_net_accounts_receivable = values[1];
		solve();
	}

	@Override
	public String getSolvedEquationString() {
		return "( " + net_credit_sales +" / " +average_net_accounts_receivable +" ) = " + value;
	}

	@Override
	public String getEquationString() {
		return "( " + FieldList.NET_CREDIT_SALES +" / " +FieldList.AVERAGE_NET_ACCOUNTS_RECEIVABLE +" ) = " + value;
	}

	@Override
	public void solve() {
		value = ( net_credit_sales / average_net_accounts_receivable );
	}

}
